package com.example.demo.Utils;

import io.jsonwebtoken.Claims;

/**
 * Created by hasee
 * on 2019/11/20 11:26
 */
public class RoleFactory {

    public boolean checkRoleOfUser(Claims claims){
        String checkResult = null;
        String userRole = "101";
        String vipUserRole = "102";
        boolean result =false;
        checkResult = claims.get("role").toString();
        if(checkResult.equals(userRole) || checkResult.equals(vipUserRole)){
            result = true;
        }else{
            result = false;
        }
        return result;
    }

    public boolean checkRoleOfAdmin(Claims claims){
        String checkResult = null;
        String adminRole = "201";
        String superAdminRole = "202";
        boolean result =false;
        checkResult = claims.get("role").toString();
        if(checkResult.equals(adminRole) || checkResult.equals(superAdminRole)){
            result = true;
        }else{
            result = false;
        }
        return result;
    }
}
